##
## Makefile for @PROJET@ in /home/hotgloupi/sandbox/cobj
##
## Made by Raphaël Londeix
## hotgloupi   <raphael.londeix@gmail.com>
##
## Started on  mer. 26 janv. 2011 15:44:43 CET Raphaël Londeix
## Last update mer. 26 janv. 2011 15:44:43 CET Raphaël Londeix
##

CC		?= gcc

BUILD_FLAGS	?= -Wall -Wextra -ggdb3
CFLAGS		+= -D_GNU_SOURCE -std=c99

LDFLAGS		+= -Llibhash/bin -lhash

TARGET		= bin/libcobj.a

SOURCE		= \
class.c \
new.c \
string.c \
raise.c \
container.c \
native_array.c \
native_stack.c \
native_list.c \

OBJS		= $(SOURCE:.c=.o)

$(TARGET): libhash/bin/libhash.a $(OBJS)
	@mkdir -p bin/
	@ar -rc $(TARGET) $(OBJS)
	ranlib $(TARGET)

$(OBJS): $(SOURCE)

libhash:
	svn checkout http://libhash.googlecode.com/svn/trunk/ libhash

libhash/bin/libhash.a: libhash
	svn up libhash
	@echo -n "Compiling libhash: "
	@make -C libhash > /dev/null && echo Done

all: $(TARGET)

clean:
	rm -f $(OBJS)

fclean: clean
	rm -f $(TARGET)

dist-clean: fclean
	rm -rf libhash
	@echo -n "Cleaning tests: "
	@make fclean -C tests/ > /dev/null && echo "Done"

re: fclean all

tests: $(TARGET)
	@make re -Ctests/ > /dev/null
	@echo -n "Testing string: "
	@./tests/string > /dev/null && echo Done
	@echo -n "Testing native_array: "
	@./tests/native_array > /dev/null && echo Done
	@echo -n "Testing native_stack: "
	@./tests/native_stack > /dev/null && echo Done
	@echo "All tests passed"

.PHONY: all clean fclean dist-clean tests
